package com.xmut.xmutbackend.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xmut.xmutbackend.entity.Notification;
import com.xmut.xmutbackend.mapper.NotificationMapper;
import com.xmut.xmutbackend.service.INotificationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class NotificationServiceImpl extends ServiceImpl<NotificationMapper, Notification> implements INotificationService {
    private static final Logger logger = LoggerFactory.getLogger(NotificationServiceImpl.class);

    @Override
    public boolean save(Notification entity) {
        try {
            logger.info("保存通知 - 开始: {}", entity);
            boolean result = super.save(entity);
            logger.info("保存通知 - 结果: {}", result);
            return result;
        } catch (Exception e) {
            logger.error("保存通知失败 - 实体内容: {}", entity);
            logger.error("保存通知失败 - 错误详情: ", e); // 打印完整堆栈
            return false;
        }
    }
}